﻿using B.MES.Customer.Application.IApplication;
using B.MES.Customer.Domain.DTO;
using B.MES.Customer.Domain;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.MES.Customer.Read.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AdditionalExpenditureController : ControllerBase
    {
        private readonly IAdditionalExpenditureApplication _additionalExpenditureApplication;

        public AdditionalExpenditureController(IAdditionalExpenditureApplication additionalExpenditureApplication)
        {
            this._additionalExpenditureApplication = additionalExpenditureApplication;
        }
        /// <summary>
        /// 支出添加
        /// </summary>
        /// <param name="additionalExpenditure"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public IActionResult AddadditionalExpenditure(AdditionalExpenditure additionalExpenditure)
        {
            var result = _additionalExpenditureApplication.AddadditionalExpenditure(additionalExpenditure);
            return Ok(result);
        }
        /// <summary>
        /// 获取支出信息
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetAdditionalExpenditure(int PageIndex, int PageSize)
        {
            var result = _additionalExpenditureApplication.GetAdditionalExpenditure(PageIndex, PageSize);
            return Ok(result);
        }
        /// <summary>
        /// 获取支付类型
        /// </summary>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult GetExpenditureType()
        {
           var result=_additionalExpenditureApplication.GetExpenditureType();
           return Ok(result);   
        }
        /// <summary>
        /// 获取支出信息反填
        /// </summary>
        /// <param name="NewExpenditureId"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public IActionResult EditAdditionalExpenditure(int NewExpenditureId)
        {
            var result=_additionalExpenditureApplication.EditAdditionalExpenditure(NewExpenditureId);
            return Ok(result);
        }
        /// <summary>
        /// 删除支出信息
        /// </summary>
        /// <param name="NewExpenditureId"></param>
        /// <returns></returns>
        /// 
        [HttpDelete]
        public IActionResult DeleteAdditionalExpenditure(int NewExpenditureId)
        {
            var result = _additionalExpenditureApplication.DeleteAdditionalExpenditure(NewExpenditureId);
            return Ok(result);
        }

        /// <summary>
        /// 批量删除支出信息
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        /// 
        [HttpPut]
        public IActionResult  DeleteAdditionalExpenditure(List<AdditionalExpenditure> list)
        {
           var result = _additionalExpenditureApplication.DeleteAdditionalExpenditure(list);    
            return Ok(result);
        }
        /// <summary>
        /// 更新支出信息
        /// </summary>
        /// <param name="additionalExpenditure"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpPut]
        public IActionResult UpdateAdditionalExpenditure(AdditionalExpenditure additionalExpenditure)
        {
            var result = _additionalExpenditureApplication.UpdateAdditionalExpenditure(additionalExpenditure);
            return Ok(result);
        }
    }
}
